package c.c.b.b.f;

import c.c.b.b.i.a;
import c.c.b.b.i.b;
import c.c.b.b.i.c;
import c.c.b.b.i.e;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
import java.util.TreeSet;

/* compiled from: BasicNetwork */
public class d implements c {
    public static final boolean c = q.a;
    public final a a;
    public final e b;

    public d(a aVar) {
        e eVar = new e(4096);
        this.a = aVar;
        this.b = eVar;
    }

    public static List<a> b(List<a> list, b.a aVar) {
        ArrayList arrayList = new ArrayList();
        TreeSet treeSet = new TreeSet(String.CASE_INSENSITIVE_ORDER);
        if (!(list == null || list.isEmpty())) {
            for (a aVar2 : list) {
                treeSet.add(aVar2.a);
                arrayList.add(aVar2);
            }
        }
        List list2 = aVar.i;
        if (list2 != null) {
            if (!list2.isEmpty()) {
                for (a aVar3 : aVar.i) {
                    if (!treeSet.contains(aVar3.a)) {
                        arrayList.add(aVar3);
                    }
                }
            }
        } else if (!aVar.h.isEmpty()) {
            for (Entry entry : aVar.h.entrySet()) {
                if (!treeSet.contains(entry.getKey())) {
                    arrayList.add(new a((String) entry.getKey(), (String) entry.getValue()));
                }
            }
        }
        return arrayList;
    }

    public static void e(String str, c<?> cVar, c.c.b.b.h.a aVar) throws c.c.b.b.h.a {
        e retryPolicy = cVar.getRetryPolicy();
        int timeoutMs = cVar.getTimeoutMs();
        try {
            i iVar = (i) retryPolicy;
            int i = iVar.b + 1;
            iVar.b = i;
            int i2 = iVar.a;
            iVar.a = i2 + ((int) (((float) i2) * iVar.d));
            if ((i <= iVar.c ? 1 : null) != null) {
                cVar.addMarker(String.format("%s-retry [timeout=%s]", new Object[]{str, Integer.valueOf(timeoutMs)}));
                return;
            }
            throw aVar;
        } catch (c.c.b.b.h.a aVar2) {
            cVar.addMarker(String.format("%s-timeout-giveup [timeout=%s]", new Object[]{str, Integer.valueOf(timeoutMs)}));
            throw aVar2;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:127:0x0004 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:107:0x017c A:{SYNTHETIC, Splitter:B:107:0x017c} */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x014e A:{SYNTHETIC, Splitter:B:98:0x014e} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A:{SYNTHETIC, Splitter:B:67:0x00cf} */
    /* JADX WARNING: Removed duplicated region for block: B:114:0x0188 A:{SYNTHETIC, Splitter:B:114:0x0188} */
    /* JADX WARNING: Removed duplicated region for block: B:62:? A:{SYNTHETIC, ExcHandler: SocketTimeoutException (unused java.net.SocketTimeoutException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00bf A:{ExcHandler: MalformedURLException (e java.net.MalformedURLException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A:{SYNTHETIC, Splitter:B:67:0x00cf} */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x014e A:{SYNTHETIC, Splitter:B:98:0x014e} */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00b6 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:62:? A:{SYNTHETIC, ExcHandler: SocketTimeoutException (unused java.net.SocketTimeoutException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00bf A:{ExcHandler: MalformedURLException (e java.net.MalformedURLException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x014e A:{SYNTHETIC, Splitter:B:98:0x014e} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A:{SYNTHETIC, Splitter:B:67:0x00cf} */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00b6 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:62:? A:{SYNTHETIC, ExcHandler: SocketTimeoutException (unused java.net.SocketTimeoutException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00bf A:{ExcHandler: MalformedURLException (e java.net.MalformedURLException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A:{SYNTHETIC, Splitter:B:67:0x00cf} */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x014e A:{SYNTHETIC, Splitter:B:98:0x014e} */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00b6 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:62:? A:{SYNTHETIC, ExcHandler: SocketTimeoutException (unused java.net.SocketTimeoutException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:59:0x00bf A:{ExcHandler: MalformedURLException (e java.net.MalformedURLException), Splitter:B:5:0x001b} */
    /* JADX WARNING: Removed duplicated region for block: B:98:0x014e A:{SYNTHETIC, Splitter:B:98:0x014e} */
    /* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A:{SYNTHETIC, Splitter:B:67:0x00cf} */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00b6 A:{ExcHandler: all (th java.lang.Throwable), Splitter:B:5:0x001b} */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:27:0x0065, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:28:0x0066, code skipped:
            r13 = null;
            r2 = r11;
            r17 = r12;
     */
    /* JADX WARNING: Missing block: B:51:0x00ab, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:52:0x00ac, code skipped:
            r1 = r12;
     */
    /* JADX WARNING: Missing block: B:54:0x00b3, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:55:0x00b4, code skipped:
            r1 = r12;
     */
    /* JADX WARNING: Missing block: B:56:0x00b6, code skipped:
            r0 = th;
     */
    /* JADX WARNING: Missing block: B:57:0x00b9, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:58:0x00ba, code skipped:
            r17 = r1;
            r13 = null;
            r2 = r11;
     */
    /* JADX WARNING: Missing block: B:59:0x00bf, code skipped:
            r0 = e;
     */
    /* JADX WARNING: Missing block: B:60:0x00c0, code skipped:
            r2 = r11;
     */
    /* JADX WARNING: Missing block: B:61:0x00c3, code skipped:
            r2 = r11;
     */
    /* JADX WARNING: Missing block: B:68:?, code skipped:
            r0 = r2.a;
            c.c.b.b.f.q.d("Unexpected response code %d for %s", java.lang.Integer.valueOf(r0), r22.getUrl());
     */
    /* JADX WARNING: Missing block: B:69:0x00e7, code skipped:
            if (r13 != null) goto L_0x00e9;
     */
    /* JADX WARNING: Missing block: B:70:0x00e9, code skipped:
            r11 = new c.c.b.b.f.m(r0, r13, false, android.os.SystemClock.elapsedRealtime() - r9, r17);
     */
    /* JADX WARNING: Missing block: B:71:0x00f9, code skipped:
            if (r0 != com.huawei.agconnect.exception.AGCServerException.TOKEN_INVALID) goto L_0x00fb;
     */
    /* JADX WARNING: Missing block: B:73:0x00fd, code skipped:
            if (r0 == com.huawei.agconnect.exception.AGCServerException.AUTHENTICATION_FAILED) goto L_0x00ff;
     */
    /* JADX WARNING: Missing block: B:76:0x0102, code skipped:
            if (r0 >= com.huawei.agconnect.exception.AGCServerException.AUTHENTICATION_INVALID) goto L_0x0104;
     */
    /* JADX WARNING: Missing block: B:78:0x0106, code skipped:
            if (r0 > 499) goto L_0x0108;
     */
    /* JADX WARNING: Missing block: B:81:0x010e, code skipped:
            throw new c.c.b.b.h.c(r11);
     */
    /* JADX WARNING: Missing block: B:83:0x0111, code skipped:
            if (r0 < com.huawei.agconnect.exception.AGCServerException.UNKNOW_EXCEPTION) goto L_0x012e;
     */
    /* JADX WARNING: Missing block: B:87:0x011b, code skipped:
            if (r22.shouldRetryServerErrors() != false) goto L_0x011d;
     */
    /* JADX WARNING: Missing block: B:88:0x011d, code skipped:
            e("server", r8, new c.c.b.b.h.g(r11));
     */
    /* JADX WARNING: Missing block: B:90:0x012d, code skipped:
            throw new c.c.b.b.h.g(r11);
     */
    /* JADX WARNING: Missing block: B:93:0x0134, code skipped:
            e("auth", r8, new c.c.b.b.h.b(r11));
     */
    /* JADX WARNING: Missing block: B:94:0x013f, code skipped:
            e("network", r8, new c.c.b.b.h.d());
     */
    /* JADX WARNING: Missing block: B:96:?, code skipped:
            r0 = r2.d;
     */
    /* JADX WARNING: Missing block: B:97:0x014b, code skipped:
            if (r0 == null) goto L_0x0004;
     */
    /* JADX WARNING: Missing block: B:100:0x0153, code skipped:
            throw new c.c.b.b.h.e(r0);
     */
    /* JADX WARNING: Missing block: B:108:?, code skipped:
            r0 = r2.d;
     */
    /* JADX WARNING: Missing block: B:109:0x017e, code skipped:
            if (r0 == null) goto L_0x0004;
     */
    /* JADX WARNING: Missing block: B:110:0x0180, code skipped:
            r0.close();
     */
    /* JADX WARNING: Missing block: B:115:?, code skipped:
            r1 = r11.d;
     */
    /* JADX WARNING: Missing block: B:116:0x018a, code skipped:
            if (r1 != null) goto L_0x018c;
     */
    /* JADX WARNING: Missing block: B:117:0x018c, code skipped:
            r1.close();
     */
    public c.c.b.b.f.m a(c.c.b.b.f.c<?> r22) throws c.c.b.b.h.a {
        /*
        r21 = this;
        r7 = r21;
        r8 = r22;
    L_0x0004:
        r9 = android.os.SystemClock.elapsedRealtime();
        r1 = java.util.Collections.emptyList();
        r2 = 0;
        r0 = r22.getCacheEntry();	 Catch:{ SocketTimeoutException -> 0x0170, MalformedURLException -> 0x0154, IOException -> 0x00c9 }
        r0 = r7.c(r0);	 Catch:{ SocketTimeoutException -> 0x0170, MalformedURLException -> 0x0154, IOException -> 0x00c9 }
        r3 = r7.a;	 Catch:{ SocketTimeoutException -> 0x0170, MalformedURLException -> 0x0154, IOException -> 0x00c9 }
        r11 = r3.a(r8, r0);	 Catch:{ SocketTimeoutException -> 0x0170, MalformedURLException -> 0x0154, IOException -> 0x00c9 }
        r13 = r11.a;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00b9, all -> 0x00b6 }
        r12 = r11.a();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00b9, all -> 0x00b6 }
        r0 = 304; // 0x130 float:4.26E-43 double:1.5E-321;
        if (r13 != r0) goto L_0x006c;
    L_0x0025:
        r0 = r22.getCacheEntry();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        if (r0 != 0) goto L_0x0047;
    L_0x002b:
        r0 = new c.c.b.b.f.m;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r15 = 304; // 0x130 float:4.26E-43 double:1.5E-321;
        r16 = 0;
        r17 = 1;
        r3 = android.os.SystemClock.elapsedRealtime();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r18 = r3 - r9;
        r14 = r0;
        r20 = r12;
        r14.m1022init(r15, r16, r17, r18, r20);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r1 = r11.d;	 Catch:{ all -> 0x0046 }
        if (r1 == 0) goto L_0x0046;
    L_0x0043:
        r1.close();	 Catch:{ all -> 0x0046 }
    L_0x0046:
        return r0;
    L_0x0047:
        r19 = b(r12, r0);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r1 = new c.c.b.b.f.m;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r14 = 304; // 0x130 float:4.26E-43 double:1.5E-321;
        r15 = r0.b;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r16 = 1;
        r3 = android.os.SystemClock.elapsedRealtime();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r17 = r3 - r9;
        r13 = r1;
        r13.m1022init(r14, r15, r16, r17, r19);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x0065, all -> 0x00b6 }
        r0 = r11.d;	 Catch:{ all -> 0x0064 }
        if (r0 == 0) goto L_0x0064;
    L_0x0061:
        r0.close();	 Catch:{ all -> 0x0064 }
    L_0x0064:
        return r1;
    L_0x0065:
        r0 = move-exception;
        r13 = r2;
        r2 = r11;
        r17 = r12;
        goto L_0x00cd;
    L_0x006c:
        r19 = r7.f(r8, r11);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00b3, all -> 0x00b6 }
        r0 = android.os.SystemClock.elapsedRealtime();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00ab, all -> 0x00b6 }
        r2 = r0 - r9;
        r1 = r21;
        r4 = r22;
        r5 = r19;
        r6 = r13;
        r1.d(r2, r4, r5, r6);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00ab, all -> 0x00b6 }
        r0 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        if (r13 < r0) goto L_0x00a2;
    L_0x0084:
        r0 = 299; // 0x12b float:4.19E-43 double:1.477E-321;
        if (r13 > r0) goto L_0x00a2;
    L_0x0088:
        r0 = new c.c.b.b.f.m;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00ab, all -> 0x00b6 }
        r15 = 0;
        r1 = android.os.SystemClock.elapsedRealtime();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00ab, all -> 0x00b6 }
        r16 = r1 - r9;
        r1 = r12;
        r12 = r0;
        r14 = r19;
        r18 = r1;
        r12.m1022init(r13, r14, r15, r16, r18);	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00a9, all -> 0x00b6 }
        r1 = r11.d;	 Catch:{ all -> 0x00a1 }
        if (r1 == 0) goto L_0x00a1;
    L_0x009e:
        r1.close();	 Catch:{ all -> 0x00a1 }
    L_0x00a1:
        return r0;
    L_0x00a2:
        r1 = r12;
        r0 = new java.io.IOException;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00a9, all -> 0x00b6 }
        r0.<init>();	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00a9, all -> 0x00b6 }
        throw r0;	 Catch:{ SocketTimeoutException -> 0x00c3, MalformedURLException -> 0x00bf, IOException -> 0x00a9, all -> 0x00b6 }
    L_0x00a9:
        r0 = move-exception;
        goto L_0x00ad;
    L_0x00ab:
        r0 = move-exception;
        r1 = r12;
    L_0x00ad:
        r17 = r1;
        r2 = r11;
        r13 = r19;
        goto L_0x00cd;
    L_0x00b3:
        r0 = move-exception;
        r1 = r12;
        goto L_0x00ba;
    L_0x00b6:
        r0 = move-exception;
        goto L_0x0186;
    L_0x00b9:
        r0 = move-exception;
    L_0x00ba:
        r17 = r1;
        r13 = r2;
        r2 = r11;
        goto L_0x00cd;
    L_0x00bf:
        r0 = move-exception;
        r2 = r11;
        goto L_0x0155;
    L_0x00c3:
        r2 = r11;
        goto L_0x0170;
    L_0x00c6:
        r0 = move-exception;
        goto L_0x0185;
    L_0x00c9:
        r0 = move-exception;
        r17 = r1;
        r13 = r2;
    L_0x00cd:
        if (r2 == 0) goto L_0x014e;
    L_0x00cf:
        r0 = r2.a;	 Catch:{ all -> 0x00c6 }
        r1 = "Unexpected response code %d for %s";
        r3 = 2;
        r3 = new java.lang.Object[r3];	 Catch:{ all -> 0x00c6 }
        r4 = 0;
        r5 = java.lang.Integer.valueOf(r0);	 Catch:{ all -> 0x00c6 }
        r3[r4] = r5;	 Catch:{ all -> 0x00c6 }
        r4 = 1;
        r5 = r22.getUrl();	 Catch:{ all -> 0x00c6 }
        r3[r4] = r5;	 Catch:{ all -> 0x00c6 }
        c.c.b.b.f.q.d(r1, r3);	 Catch:{ all -> 0x00c6 }
        if (r13 == 0) goto L_0x013f;
    L_0x00e9:
        r1 = new c.c.b.b.f.m;	 Catch:{ all -> 0x00c6 }
        r14 = 0;
        r3 = android.os.SystemClock.elapsedRealtime();	 Catch:{ all -> 0x00c6 }
        r15 = r3 - r9;
        r11 = r1;
        r12 = r0;
        r11.m1022init(r12, r13, r14, r15, r17);	 Catch:{ all -> 0x00c6 }
        r3 = 401; // 0x191 float:5.62E-43 double:1.98E-321;
        if (r0 == r3) goto L_0x0134;
    L_0x00fb:
        r3 = 403; // 0x193 float:5.65E-43 double:1.99E-321;
        if (r0 != r3) goto L_0x0100;
    L_0x00ff:
        goto L_0x0134;
    L_0x0100:
        r3 = 400; // 0x190 float:5.6E-43 double:1.976E-321;
        if (r0 < r3) goto L_0x010f;
    L_0x0104:
        r3 = 499; // 0x1f3 float:6.99E-43 double:2.465E-321;
        if (r0 <= r3) goto L_0x0109;
    L_0x0108:
        goto L_0x010f;
    L_0x0109:
        r0 = new c.c.b.b.h.c;	 Catch:{ all -> 0x00c6 }
        r0.m7932init(r1);	 Catch:{ all -> 0x00c6 }
        throw r0;	 Catch:{ all -> 0x00c6 }
    L_0x010f:
        r3 = 500; // 0x1f4 float:7.0E-43 double:2.47E-321;
        if (r0 < r3) goto L_0x012e;
    L_0x0113:
        r3 = 599; // 0x257 float:8.4E-43 double:2.96E-321;
        if (r0 > r3) goto L_0x012e;
    L_0x0117:
        r0 = r22.shouldRetryServerErrors();	 Catch:{ all -> 0x00c6 }
        if (r0 == 0) goto L_0x0128;
    L_0x011d:
        r0 = "server";
        r3 = new c.c.b.b.h.g;	 Catch:{ all -> 0x00c6 }
        r3.m5367init(r1);	 Catch:{ all -> 0x00c6 }
        e(r0, r8, r3);	 Catch:{ all -> 0x00c6 }
        goto L_0x0149;
    L_0x0128:
        r0 = new c.c.b.b.h.g;	 Catch:{ all -> 0x00c6 }
        r0.m5367init(r1);	 Catch:{ all -> 0x00c6 }
        throw r0;	 Catch:{ all -> 0x00c6 }
    L_0x012e:
        r0 = new c.c.b.b.h.g;	 Catch:{ all -> 0x00c6 }
        r0.m5367init(r1);	 Catch:{ all -> 0x00c6 }
        throw r0;	 Catch:{ all -> 0x00c6 }
    L_0x0134:
        r0 = "auth";
        r3 = new c.c.b.b.h.b;	 Catch:{ all -> 0x00c6 }
        r3.m5362init(r1);	 Catch:{ all -> 0x00c6 }
        e(r0, r8, r3);	 Catch:{ all -> 0x00c6 }
        goto L_0x0149;
    L_0x013f:
        r0 = "network";
        r1 = new c.c.b.b.h.d;	 Catch:{ all -> 0x00c6 }
        r1.m5363init();	 Catch:{ all -> 0x00c6 }
        e(r0, r8, r1);	 Catch:{ all -> 0x00c6 }
    L_0x0149:
        r0 = r2.d;	 Catch:{ all -> 0x0004 }
        if (r0 == 0) goto L_0x0004;
    L_0x014d:
        goto L_0x0180;
    L_0x014e:
        r1 = new c.c.b.b.h.e;	 Catch:{ all -> 0x00c6 }
        r1.m7933init(r0);	 Catch:{ all -> 0x00c6 }
        throw r1;	 Catch:{ all -> 0x00c6 }
    L_0x0154:
        r0 = move-exception;
    L_0x0155:
        r1 = new java.lang.RuntimeException;	 Catch:{ all -> 0x00c6 }
        r3 = new java.lang.StringBuilder;	 Catch:{ all -> 0x00c6 }
        r3.<init>();	 Catch:{ all -> 0x00c6 }
        r4 = "Bad URL ";
        r3.append(r4);	 Catch:{ all -> 0x00c6 }
        r4 = r22.getUrl();	 Catch:{ all -> 0x00c6 }
        r3.append(r4);	 Catch:{ all -> 0x00c6 }
        r3 = r3.toString();	 Catch:{ all -> 0x00c6 }
        r1.<init>(r3, r0);	 Catch:{ all -> 0x00c6 }
        throw r1;	 Catch:{ all -> 0x00c6 }
    L_0x0170:
        r0 = "socket";
        r1 = new c.c.b.b.h.h;	 Catch:{ all -> 0x00c6 }
        r1.m5368init();	 Catch:{ all -> 0x00c6 }
        e(r0, r8, r1);	 Catch:{ all -> 0x00c6 }
        if (r2 == 0) goto L_0x0004;
    L_0x017c:
        r0 = r2.d;	 Catch:{ all -> 0x0004 }
        if (r0 == 0) goto L_0x0004;
    L_0x0180:
        r0.close();	 Catch:{ all -> 0x0004 }
        goto L_0x0004;
    L_0x0185:
        r11 = r2;
    L_0x0186:
        if (r11 == 0) goto L_0x018f;
    L_0x0188:
        r1 = r11.d;	 Catch:{ all -> 0x018f }
        if (r1 == 0) goto L_0x018f;
    L_0x018c:
        r1.close();	 Catch:{ all -> 0x018f }
    L_0x018f:
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.b.f.d.a(c.c.b.b.f.c):c.c.b.b.f.m");
    }

    public final Map<String, String> c(b.a aVar) {
        if (aVar == null) {
            return Collections.emptyMap();
        }
        HashMap hashMap = new HashMap();
        String str = aVar.c;
        if (str != null) {
            hashMap.put("If-None-Match", str);
        }
        long j = aVar.e;
        if (j > 0) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
            simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
            hashMap.put("If-Modified-Since", simpleDateFormat.format(new Date(j)));
        }
        return hashMap;
    }

    public final void d(long j, c<?> cVar, byte[] bArr, int i) {
        if (c || j > 3000) {
            Object[] objArr = new Object[5];
            objArr[0] = cVar;
            objArr[1] = Long.valueOf(j);
            objArr[2] = bArr != null ? Integer.valueOf(bArr.length) : "null";
            objArr[3] = Integer.valueOf(i);
            objArr[4] = Integer.valueOf(((i) cVar.getRetryPolicy()).b);
            q.c("HTTP response for request=<%s> [lifetime=%d], [size=%s], [rc=%d], [retryCount=%s]", objArr);
        }
    }

    /* JADX WARNING: Missing exception handler attribute for start block: B:71:0x0148 */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:72:?, code skipped:
            c.c.b.b.f.q.a("Error occured when FileRequest.parseHttpResponse", new java.lang.Object[0]);
     */
    /* JADX WARNING: Missing block: B:73:0x0150, code skipped:
            if (r5 != null) goto L_0x0152;
     */
    /* JADX WARNING: Missing block: B:75:?, code skipped:
            r5.close();
     */
    /* JADX WARNING: Missing block: B:76:0x0156, code skipped:
            c.c.b.b.f.q.a(r9, new java.lang.Object[0]);
     */
    /* JADX WARNING: Missing block: B:78:0x015b, code skipped:
            if (r5 != null) goto L_0x015d;
     */
    /* JADX WARNING: Missing block: B:80:?, code skipped:
            r5.close();
     */
    /* JADX WARNING: Missing block: B:81:0x0161, code skipped:
            c.c.b.b.f.q.a(r8, new java.lang.Object[0]);
     */
    /* JADX WARNING: Missing block: B:84:?, code skipped:
            r4.close();
     */
    /* JADX WARNING: Missing block: B:85:0x016b, code skipped:
            c.c.b.b.f.q.a(r3, new java.lang.Object[0]);
     */
    /* JADX WARNING: Missing block: B:89:0x0174, code skipped:
            if (r5 != null) goto L_0x0176;
     */
    /* JADX WARNING: Missing block: B:91:?, code skipped:
            r5.close();
     */
    /* JADX WARNING: Missing block: B:92:0x017a, code skipped:
            r2 = 0;
            c.c.b.b.f.q.a(r9, new java.lang.Object[0]);
     */
    /* JADX WARNING: Missing block: B:94:0x0181, code skipped:
            r2 = 0;
     */
    /* JADX WARNING: Missing block: B:98:0x0188, code skipped:
            c.c.b.b.f.q.a(r8, new java.lang.Object[r2]);
     */
    /* JADX WARNING: Missing block: B:102:0x0191, code skipped:
            c.c.b.b.f.q.a(r3, new java.lang.Object[r2]);
     */
    public byte[] f(c.c.b.b.f.c<?> r20, c.c.b.b.f.b r21) throws java.io.IOException, c.c.b.b.h.g {
        /*
        r19 = this;
        r1 = r19;
        r0 = r20;
        r2 = r21;
        r3 = r0 instanceof c.c.b.b.d.e;
        r6 = 0;
        r7 = -1;
        if (r3 == 0) goto L_0x0197;
    L_0x000c:
        r0 = (c.c.b.b.d.e) r0;
        r3 = "Error occured when calling tmpFile.close";
        r8 = "Error occured when calling consumingContent";
        r9 = "Error occured when calling InputStream.close";
        r10 = r2.c;
        r10 = (long) r10;
        r12 = 0;
        r14 = (r10 > r12 ? 1 : (r10 == r12 ? 0 : -1));
        if (r14 > 0) goto L_0x0024;
    L_0x001d:
        r14 = new java.lang.Object[r6];
        r15 = "Response doesn't present Content-Length!";
        c.c.b.b.f.q.c(r15, r14);
    L_0x0024:
        r14 = r0.y;
        r14 = r14.length();
        r5 = "Accept-Ranges";
        r5 = r0.j(r2, r5);
        r6 = "bytes";
        r5 = android.text.TextUtils.equals(r5, r6);
        r16 = 1;
        r4 = "Content-Range";
        if (r5 == 0) goto L_0x003d;
    L_0x003c:
        goto L_0x004c;
    L_0x003d:
        r5 = r0.j(r2, r4);
        if (r5 == 0) goto L_0x004a;
    L_0x0043:
        r5 = r5.startsWith(r6);
        if (r5 == 0) goto L_0x004a;
    L_0x0049:
        goto L_0x004c;
    L_0x004a:
        r16 = 0;
    L_0x004c:
        if (r16 == 0) goto L_0x00ae;
    L_0x004e:
        r10 = r10 + r14;
        r4 = r0.j(r2, r4);
        r5 = android.text.TextUtils.isEmpty(r4);
        if (r5 != 0) goto L_0x00ab;
    L_0x0059:
        r5 = new java.lang.StringBuilder;
        r5.<init>();
        r6 = "bytes ";
        r5.append(r6);
        r5.append(r14);
        r6 = "-";
        r5.append(r6);
        r17 = 1;
        r12 = r10 - r17;
        r5.append(r12);
        r5 = r5.toString();
        r6 = android.text.TextUtils.indexOf(r4, r5);
        if (r6 == r7) goto L_0x007d;
    L_0x007c:
        goto L_0x00ab;
    L_0x007d:
        r2 = new java.lang.IllegalStateException;
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r6 = "The Content-Range Header is invalid Assume[";
        r3.append(r6);
        r3.append(r5);
        r5 = "] vs Real[";
        r3.append(r5);
        r3.append(r4);
        r4 = "], please remove the temporary file [";
        r3.append(r4);
        r0 = r0.y;
        r3.append(r0);
        r0 = "].";
        r3.append(r0);
        r0 = r3.toString();
        r2.<init>(r0);
        throw r2;
    L_0x00ab:
        r4 = 0;
        goto L_0x00af;
    L_0x00ae:
        r4 = r12;
    L_0x00af:
        r6 = (r10 > r4 ? 1 : (r10 == r4 ? 0 : -1));
        if (r6 <= 0) goto L_0x00ca;
    L_0x00b3:
        r4 = r0.x;
        r4 = r4.length();
        r6 = (r4 > r10 ? 1 : (r4 == r10 ? 0 : -1));
        if (r6 != 0) goto L_0x00ca;
    L_0x00bd:
        r2 = r0.x;
        r3 = r0.y;
        r2.renameTo(r3);
        r0.a(r10, r10);
    L_0x00c7:
        r3 = 0;
        goto L_0x0172;
    L_0x00ca:
        r4 = r0.x;
        if (r4 == 0) goto L_0x00d9;
    L_0x00ce:
        r4 = r4.exists();
        if (r4 == 0) goto L_0x00d9;
    L_0x00d4:
        r4 = r0.x;
        r4.delete();
    L_0x00d9:
        r4 = new java.io.RandomAccessFile;	 Catch:{ all -> 0x00f1 }
        r5 = r0.y;	 Catch:{ all -> 0x00f1 }
        r6 = "rw";
        r4.<init>(r5, r6);	 Catch:{ all -> 0x00f1 }
        if (r16 == 0) goto L_0x00e8;
    L_0x00e4:
        r4.seek(r14);	 Catch:{ all -> 0x00ef }
        goto L_0x00ef;
    L_0x00e8:
        r5 = 0;
        r4.setLength(r5);	 Catch:{ all -> 0x00ef }
        r12 = r5;
        goto L_0x00f3;
    L_0x00ef:
        r12 = r14;
        goto L_0x00f3;
    L_0x00f1:
        r12 = r14;
        r4 = 0;
    L_0x00f3:
        r5 = r2.d;	 Catch:{ all -> 0x0147 }
        r6 = "Content-Encoding";
        r2 = r0.j(r2, r6);	 Catch:{ all -> 0x0148 }
        r6 = "gzip";
        r2 = android.text.TextUtils.equals(r2, r6);	 Catch:{ all -> 0x0148 }
        if (r2 == 0) goto L_0x010d;
    L_0x0103:
        r2 = r5 instanceof java.util.zip.GZIPInputStream;	 Catch:{ all -> 0x0148 }
        if (r2 != 0) goto L_0x010d;
    L_0x0107:
        r2 = new java.util.zip.GZIPInputStream;	 Catch:{ all -> 0x0148 }
        r2.<init>(r5);	 Catch:{ all -> 0x0148 }
        r5 = r2;
    L_0x010d:
        r2 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
        r2 = new byte[r2];	 Catch:{ all -> 0x0148 }
        r0.a(r12, r10);	 Catch:{ all -> 0x0148 }
    L_0x0114:
        r6 = r5.read(r2);	 Catch:{ all -> 0x0148 }
        if (r6 == r7) goto L_0x0129;
    L_0x011a:
        r14 = 0;
        r4.write(r2, r14, r6);	 Catch:{ all -> 0x0148 }
        r14 = (long) r6;	 Catch:{ all -> 0x0148 }
        r12 = r12 + r14;
        r0.a(r12, r10);	 Catch:{ all -> 0x0148 }
        r6 = r0.isCanceled();	 Catch:{ all -> 0x0148 }
        if (r6 == 0) goto L_0x0114;
    L_0x0129:
        r5.close();	 Catch:{ all -> 0x012e }
        r2 = 0;
        goto L_0x0134;
    L_0x012e:
        r2 = 0;
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r9, r0);
    L_0x0134:
        r5.close();	 Catch:{ all -> 0x0138 }
        goto L_0x013d;
    L_0x0138:
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r8, r0);
    L_0x013d:
        r4.close();	 Catch:{ all -> 0x0141 }
        goto L_0x00c7;
    L_0x0141:
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r3, r0);
        goto L_0x00c7;
    L_0x0147:
        r5 = 0;
    L_0x0148:
        r0 = "Error occured when FileRequest.parseHttpResponse";
        r2 = 0;
        r6 = new java.lang.Object[r2];	 Catch:{ all -> 0x0173 }
        c.c.b.b.f.q.a(r0, r6);	 Catch:{ all -> 0x0173 }
        if (r5 == 0) goto L_0x015b;
    L_0x0152:
        r5.close();	 Catch:{ all -> 0x0156 }
        goto L_0x015b;
    L_0x0156:
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r9, r0);
    L_0x015b:
        if (r5 == 0) goto L_0x0166;
    L_0x015d:
        r5.close();	 Catch:{ all -> 0x0161 }
        goto L_0x0166;
    L_0x0161:
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r8, r0);
    L_0x0166:
        r4.close();	 Catch:{ all -> 0x016b }
        goto L_0x00c7;
    L_0x016b:
        r0 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r3, r0);
        goto L_0x00c7;
    L_0x0172:
        return r3;
    L_0x0173:
        r0 = move-exception;
        if (r5 == 0) goto L_0x0181;
    L_0x0176:
        r5.close();	 Catch:{ all -> 0x017a }
        goto L_0x0181;
    L_0x017a:
        r2 = 0;
        r6 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r9, r6);
        goto L_0x0182;
    L_0x0181:
        r2 = 0;
    L_0x0182:
        if (r5 == 0) goto L_0x018d;
    L_0x0184:
        r5.close();	 Catch:{ all -> 0x0188 }
        goto L_0x018d;
    L_0x0188:
        r5 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r8, r5);
    L_0x018d:
        r4.close();	 Catch:{ all -> 0x0191 }
        goto L_0x0196;
    L_0x0191:
        r2 = new java.lang.Object[r2];
        c.c.b.b.f.q.a(r3, r2);
    L_0x0196:
        throw r0;
    L_0x0197:
        r3 = 0;
        r4 = r2.d;
        if (r4 == 0) goto L_0x01e5;
    L_0x019c:
        r0 = r2.c;
        r2 = new c.c.b.b.f.f;
        r5 = r1.b;
        r2.m1011init(r5, r0);
        r5 = "Error occurred when closing InputStream";
        r0 = r1.b;	 Catch:{ all -> 0x01d1 }
        r6 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
        r3 = r0.b(r6);	 Catch:{ all -> 0x01d1 }
    L_0x01af:
        r0 = r4.read(r3);	 Catch:{ all -> 0x01d1 }
        if (r0 == r7) goto L_0x01ba;
    L_0x01b5:
        r6 = 0;
        r2.write(r3, r6, r0);	 Catch:{ all -> 0x01d1 }
        goto L_0x01af;
    L_0x01ba:
        r0 = r2.toByteArray();	 Catch:{ all -> 0x01d1 }
        r4.close();	 Catch:{ IOException -> 0x01c2 }
        goto L_0x01c8;
    L_0x01c2:
        r4 = 0;
        r4 = new java.lang.Object[r4];
        c.c.b.b.f.q.a(r5, r4);
    L_0x01c8:
        r4 = r1.b;
        r4.a(r3);
        r2.close();
        goto L_0x01e8;
    L_0x01d1:
        r0 = move-exception;
        r4.close();	 Catch:{ IOException -> 0x01d6 }
        goto L_0x01dc;
    L_0x01d6:
        r4 = 0;
        r4 = new java.lang.Object[r4];
        c.c.b.b.f.q.a(r5, r4);
    L_0x01dc:
        r4 = r1.b;
        r4.a(r3);
        r2.close();
        throw r0;
    L_0x01e5:
        r4 = 0;
        r0 = new byte[r4];
    L_0x01e8:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.b.f.d.f(c.c.b.b.f.c, c.c.b.b.f.b):byte[]");
    }
}
